package com.siam.package_rider.service_impl;

import java.util.Date;
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.siam.package_rider.entity.TbDeliveryAreaConfig;
import com.siam.package_rider.model.param.TbDeliveryAreaConfigParam;
import com.siam.package_rider.mapper.TbDeliveryAreaConfigMapper;
import com.siam.package_rider.service.TbDeliveryAreaConfigService;

/**
 * ---------------------------
 * 配送区域配置表 (TbDeliveryAreaConfigServiceImpl)         
 * ---------------------------
 * 作者：  高品
 * 时间：  2025-03-29 18:55:18
 * ---------------------------
 */
@Service
public class TbDeliveryAreaConfigServiceImpl extends ServiceImpl<TbDeliveryAreaConfigMapper, TbDeliveryAreaConfig> implements TbDeliveryAreaConfigService {

	@Autowired
	private TbDeliveryAreaConfigMapper tbDeliveryAreaConfigMapper;

	@Override
	public void insert(TbDeliveryAreaConfigParam param) {
		TbDeliveryAreaConfig record = new TbDeliveryAreaConfig();
		BeanUtils.copyProperties(param, record);
		record.setCreateTime(new Date());
        tbDeliveryAreaConfigMapper.insert(record);
	}

	@Override
	public void delete(Long id) {
		tbDeliveryAreaConfigMapper.deleteById(id);
	}

	@Override
	public void batchDelete(List<Long> idList) {
		tbDeliveryAreaConfigMapper.deleteBatchIds(idList);
	}

	@Override
	public void update(TbDeliveryAreaConfigParam param) {
		TbDeliveryAreaConfig record = new TbDeliveryAreaConfig();
		BeanUtils.copyProperties(param, record);
		record.setUpdateTime(new Date());
		tbDeliveryAreaConfigMapper.updateById(record);
	}

	@Override
	public Page<TbDeliveryAreaConfig> page(TbDeliveryAreaConfigParam param) {
        Page<TbDeliveryAreaConfig> page = tbDeliveryAreaConfigMapper.page(new Page(param.getPageNo(), param.getPageSize()), param);
        return page;
	}

	@Override
	public TbDeliveryAreaConfig findById(Long id) {
		return tbDeliveryAreaConfigMapper.selectById(id);
	}
}
